package com.yigou.alipay.config;

import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

@Component
public class AliPayConfig {

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "xxxxxxxx";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCrWi3Y81PI8t3s5NCpdGcptpaM6aQtn852VxNKT2USxmRZPyBN5LuWPBk/dJt9+6EkmDec9r10l3kgWHwRYM9VauwiwBfPD3JZf+DC5RRMTg/BnHb9WAiEgTGYCL18e1VXTnwgEYTPpZBKNEnCb1QN6kV+tqmcjoE+9gFaiuGqPLWcstld7oU6ejHeusTVTe8ulqGgeiRKbJ+42SrUVJnYdVtLOZh2ugSameZjAFGIfCbYh57bF2W+0hcdmXOtUywrgADgLEQiqj5QmEoJDdxvpjDO1yld/vrcPiopQRVCUvt0v+itDTkbay4ERejxVJeirSsWWgf7RDywzQLnu7VFAgMBAAECggEAKKLMOKUL+53ND378FROr23KXpXdLHh7F4b6ornjBqYAvEBMuYAqcifZarnfC4E+qWXlXxvuk1l+NtCQH2D8zLDidI2iWvN4W6i6vaMjW1Xm1tt6aQV59Np9E2Z9JAJpnFLtiKGC/NFc5Lr/Tti6cqmgibvh2pNAOypWgoI5LEgnL9sT4EOEKjVdrp2klv4jSCgSnlhwf+j6wW1o9cIERxqi+sHjalEMzyAmquq97OPbix5x0ilBGUPtw3eVOL9wHNUljD59+4pn0qPGITCwnlyiY7egTaHWukQsL6UyPCUKL7DVVlFJfJpqGOa+8vloqG8owEUz8lmy0oZo6OWPaAQKBgQDksSxUm+FxM3YBAvtTLWZ+bamBobDOh2EU0o9xjzIOOPmhb0W5hY2MQ7rAK9ku90H5LVv4wnmsOZktMtMdduihppunRZszMQGJyFJYs5CbdLgSvvM9zllsqQB8sJSgPm6oPfNaOVHOHqzf0+B3Hreh67i72B0A5icZyDTq0RFghQKBgQC/0DNKc5AJNz7QH8MMcZrKA+u/da63M4Bhp30iekvqzL0HnhfcOO1Zv3EbZ4J8ynKMTkA8ViPkIMAMYuo+RtnnXR64Ii8NauAYM/gLh0qoRI39Aw8WNqZURkFia+q/LEEB1Ro04sA0DiSDjaAkVt1Bx+H0tB++QVW/e0ZuZ819wQKBgDJw3Z0/0Ia+Wf25IaPj9KJYH7YG6s9yzrfgBWF/uwOmD3FK8K8NxP22Bp/STBHu2W9TUODaTCnvfliYyDXMf10AOX64fJXa7kLsmzUTTgbrxJnl4hK0y8aKtB/MdsutWYzkNSOmVuPGokywF+dOMCSXsGRGM4d6PA+UuA8+071dAoGAR+6LHZOC44HdQ2111vfPhYy83vsB/2AH+Bc4fTKBv9bx2KZ36jVLBUoe35kMvUGqfWVm/3mKUiXZ/4skryAg3Xv1ZjYjkROQYGM01RXycHHtEYIRKVJrQ9Vo9cDksrak1kwVXNngHGVlWhRFhvswVFfiK8NU2CNmRb20Jvk0fcECgYAjQ8tG3xiN2PiwVE1uExFkA2O7y5RsK8mHAb+LKtHJwrRUx7nb5ZKtXpeik4plx5dDo4pa4Rr3LK4Uc+ZugAN5JfEZOKdhtS2v6YjOWhiR8T1wc2nmcYXo8p7S0g2kuDgVrtfFyG1b/6soWSFiQ2wTxbUXW7k+Yuv5UD/iXJ+O2Q==";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArpYTSJXd1aCHZiAUN3pDhySiJ2dxFAVl7XLHIntLq7vL+FcEl/D88+5wv7vi2fOwpHLyGJ8Mi/ImZE3P40R8QS/LcIqa/E0oZL08kk+eUPeOvpaxqvwttKNxmiuFcnF1ymbX2SgVujLkj+x90hN0cN+fkrLyvMue1hy3TGwNJ36DeLJI3sDQ94qjrywZkLneWBGuZgKxiLFp3UUk+7HdfZrKlN4/BaT7q+4Sky73sjsKDK3dB2z/XrstvukjYbdOfYDWx2TWixOjbLBbTI2zruSSlypCnCtfnc+HrUhVIcqPcxaocHR484HxsnqwfGykIi3Z1OTOAZKDx5VJcnsKmQIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://127.0.0.1:8080/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://127.0.0.1:8080/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
